<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网上银行综合管理系统 - {% block title %}管理员界面{% endblock %}</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <!-- 通用样式 -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <style>
/* 添加固定布局样式 */
        body {
            display: flex;
            flex-direction: column;
            height: 100vh;
            overflow: hidden;
            margin: 0;
            padding: 0;
        }

        .main-container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .sidebar {
            width: 250px;
            background-color: #f8f9fa;
            overflow-y: auto;
            height: calc(100vh - 60px);
            position: fixed;
            top: 60px;
            left: 0;
            z-index: 100;
            box-shadow: 2px 0 5px rgba(0,0,0,0.1);
        }

        .main-content {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            margin-left: 250px;
            margin-top: 60px;
            height: calc(100vh - 60px);
            background-color: #f8fafc;
        }

        .navbar-admin {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 1000;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        .dashboard-container {
            max-width: 1600px;
            margin: 0 auto;
        }

        @media (max-width: 992px) {
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
            }

            .sidebar.active {
                transform: translateX(0);
            }

            .main-content {
                margin-left: 0;
            }
        }
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- 顶部导航栏 -->
    <nav class="navbar navbar-admin navbar-expand-lg navbar-dark bg-primary">
        <div class="container-fluid">
            <a class="navbar-brand" href="{{ url_for('admin.adminmain') }}">
                <i class="bi bi-bank me-2"></i>网上银行综合管理系统
            </a>

            <div class="d-flex align-items-center">
                <div class="text-white me-3">
                    <span>管理员 <strong>{{ session.get('username', 'admin') }}</strong></span>
                </div>
                <a href="{{ url_for('auth.logout') }}" class="btn btn-outline-light">
                    <i class="bi bi-box-arrow-right me-1"></i>退出登录
                </a>
                <button class="btn btn-light ms-2 d-lg-none menu-toggle">
                    <i class="bi bi-list"></i>
                </button>
            </div>
        </div>
    </nav>

    <div class="main-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <ul class="sidebar-menu list-group list-group-flush">
                <li class="list-group-item">
                    <a href="{{ url_for('admin.adminmain') }}" {% if request.path == url_for('admin.adminmain') %}class="active"{% endif %}>
                        <i class="bi bi-house-door me-2"></i>
                        <span>首页</span>
                    </a>
                </li>
                <li class="list-group-item">
                    <a href="{{ url_for('admin.admin_clientmanage') }}" {% if request.path == url_for('admin.admin_clientmanage') %}class="active"{% endif %}>
                        <i class="bi bi-people me-2"></i>
                        <span>客户管理</span>
                    </a>
                </li>
                <li class="list-group-item">
                    <a href="{{ url_for('admincard.admincardmain') }}" {% if request.path == url_for('admincard.admincardmain') %}class="active"{% endif %}>
                        <i class="bi bi-credit-card me-2"></i>
                        <span>银行卡管理</span>
                    </a>
                </li>
                <li class="list-group-item">
                    <a href="{{ url_for('admintrade.admintrade') }}" {% if request.path == url_for('admintrade.admintrade') %}class="active"{% endif %}>
                        <i class="bi bi-arrow-left-right me-2"></i>
                        <span>交易管理</span>
                    </a>
                </li>
                <li class="list-group-item">
                    <a href="{{ url_for('admindeposit.admindeposit') }}" {% if request.path == url_for('admindeposit.admindeposit') %}class="active"{% endif %}>
                        <i class="bi bi-cash-stack me-2"></i>
                        <span>存款业务管理</span>
                    </a>
                </li>
                <li class="list-group-item mt-4">
                    <a href="{{ url_for('auth.logout') }}">
                        <i class="bi bi-box-arrow-left me-2"></i>
                        <span>退出登录</span>
                    </a>
                </li>
            </ul>
        </div>

        <!-- 主内容区域 -->
        <main class="main-content">
            <div class="dashboard-container">
                {% block content %}{% endblock %}
            </div>
        </main>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- 通用JS -->
    <script>
        // 菜单切换功能
        document.addEventListener('DOMContentLoaded', function() {
            const menuToggle = document.querySelector('.menu-toggle');
            const sidebar = document.querySelector('.sidebar');

            if (menuToggle) {
                menuToggle.addEventListener('click', function() {
                    sidebar.classList.toggle('active');
                });
            }

            // 侧边栏菜单激活状态
            const menuItems = document.querySelectorAll('.sidebar-menu a');
            menuItems.forEach(item => {
                item.addEventListener('click', function() {
                    menuItems.forEach(i => i.classList.remove('active'));
                    this.classList.add('active');

                    // 在移动设备上点击菜单后关闭侧边栏
                    if (window.innerWidth < 992) {
                        sidebar.classList.remove('active');
                    }
                });
            });

            // 退出登录功能
            const logoutBtn = document.querySelector('.btn-outline-light');
            if (logoutBtn) {
                logoutBtn.addEventListener('click', function(e) {
                    e.preventDefault();
                    if (confirm('确定要退出登录吗？')) {
                        window.location.href = this.href;
                    }
                });
            }
        });
    </script>
    {% block extra_js %}{% endblock %}
</body>
</html>